﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DiamonWebOnline.Models;
using System.Data;

namespace DiamonWebOnline.Controllers
{
    public class ContactController : Controller
    {
        OnlineJewelleryShoppingString db = new OnlineJewelleryShoppingString();
        //
        // GET: /Contact/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult FeedBack() 
        {
            return View();
        }

        [HttpPost]
        public ActionResult FeedBack(Inquiry inquiry) 
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //inquiry.Cdate = DateTime.Now;
                    db.Inquiries.Add(inquiry);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("","Khong luu duoc!");
            }
            return View(inquiry);
        }

    }
}
